<?php
namespace app\admin\controller;
use Symfony\Component\Yaml\Tests\DumperTest;
use think\Controller;
use think\Request;
use think\Session;
use think\Db;
use  think\table;

class Aaaaa extends Controller
{

}

//验证

$str =
<<<AB
			<head>
			<meta name="viewport" content="width=device-width, initial-scale=1" />
		
			</head>
			<div style='width:100px;margin:0 auto;margin-top:100px'>
			<img style="margin-left: 25px;" id="img" src='image.php'>
			<form action="./order.php" method="post" onsubmit='shops()'>
			<input style="width:100px;margin-top:5px" type="text" name="codes" value="">
			<input id='sh' style="width:100px;margin-top:5px" type="submit" >
			</form>
			</div>
			<script src="js/jquery.js" type="text/javascript"></script>
			<script>
			function shops(){
            setTimeout(function(){
            alert('购买人数太多，服务器正在努力提交订单...')
            $('#sh').val("插队提交中...");
            },3000)

				$('#sh').attr("disabled", true);
				$('#sh').val("正在提交...");
			}
		
			$("#img").click(function(){
				var d = new Date();
				$(this).attr('src','image.php?'+d.valueOf());
			})
			</script>
AB;

if(!isset($_POST['codes'])){//判断是否是验证码提交上来的
    if(!isset($_SESSION['userid'])){
        $_SESSION['userid']='0';
    }
    $userid=$_SESSION['userid'];
    $_SESSION['userid']=++$userid;
    if($_SESSION['userid']>="3"){
        echo '每个用户限购2单，如需改单。请电话咨询！';
        die;
        $_SESSION['userid']='3';
        echo $str;
        echo '<script>alert("你提交的次数过多，我们可能需要一些认证")</script>';
        $_SESSION['post_text']=$_POST;//保存
        die;
    }
}else{

    if($_SESSION['user_code']==strtolower($_POST['codes'])){ //验证
        $_POST=$_SESSION['post_text'];
    }else{
        $_SESSION['user_code']=null;
        echo '<script>alert("验证码错误！")</script>';
        echo $str;//如果错误，返回继续填写
        die;
    }

}
$_SESSION['post_text']=$_POST;//保存
if(isset($_POST['wfproname'])&&!empty($_POST['wfproname'])){
    $text=$_SESSION['post_text'];
    $text['es']='1';
    $_SESSION['post_text']=$text;
    header('location:orders.php');
}else{
    $text=$_SESSION['post_text'];
    $text['es']='2';
    $_SESSION['post_text']=$text;
    header('location:orders.php');
}
